<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      span {
        color: red;
      }
    </style>
  </head>
  <body>
    <a href="https://jx3.xoyo.com/gn/">支付成功<span>2</span>后跳转到首页</a>
    <script>
      // 获取元素
      const a = document.querySelector("a");
      let num = 2;
      let timerId = setInterval(function () {
        num--;
        a.innerHTML = `支付成功<span>${num}</span>后跳转到首页`;
        // 当num为0时，停止定时器
        if (num === 0) {
          clearInterval(timerId);
          // 跳转 location.href
          location.href = "https://jx3.xoyo.com/gn/";
        }
      }, 1000);
    </script>
  </body>
</html>
